package com.kstech.ks_gaz01

import android.content.Context
import android.os.Environment.getExternalStorageDirectory
import java.io.File

/**
 * author: lenovo
 * created on: 2023/12/27 10:08
 * description:存放常量参数
 * HomeFragment 类里有大量的常量没有转移
 *
 */
//正式版10.10.100.254 测试版192.168.210.239
var SOCKET_IP = "10.10.100.254"
var debug = false

//const val SOCKET_IP = "192.168.177.9"
const val SOCKET_PORT = 8899
const val test = "test"

//const val debug = true
const val XML_CONFIG = "Config"
const val XML_REALTIME = "RealTime"
const val XML_VERSION = "Version"
const val XML_SENSORSET = "SensorSet"
const val XML_REALTIME_FLOAT = "RealTimeFloat"
const val XML_SIMULATION = "Simulation"
const val XML_XMLSETTING = "XmlSetting"
const val XML_ZTPROGRESS = "ZtProgress"
const val XML_XS_BD = "是否显示标定界面"
const val XML_XS_FZ = "是否显示仿真界面"
const val XML_XS_RTB = "是否显示实时参数下边栏"
const val XML_XS_GZXX = "是否发送故障信息"
const val XML_IS_SINGLE_CONTROL = "是否单控制器"
const val XML_IS_SHOW_PROGRESSBAR_ZT = "是否显示支腿涨幅长度进度条"
//var isSendGz = false// 是否发送故障信息 如果xml 实时参数中配置了故障信息，则是发送;如果没有配置则是不发送

/**
 * 一般机型文件故障码44460-44462 44460为起始位 实际共两个
 * gnh16 44460-44465 共五个+数据头（共六个）平板发送消息 01 03 11 6C 00 06 00 E9
 */
var gz_size = 2

/**
 * 当前车型
 */
var currentCarName = ""

/**
 * 标定界面
 */
var XML_ADDRESS_SETTING_BUTTON = "43700"
var XML_ADDRESS_MIN_MAX = "43701"
var XML_ADDRESS_SENSOR_SUCCESS = "43702"

/**
 * 参数保存
 */
var XML_ADDRESS_SAVE_PARAM = "43705"
var XML_VALUE_SAVE_PARAM = "23130"
var XML_ADDRESS_SAVE_PARAM_SUCESS = "43706"//保存成功
var XML_VALUE_SAVE_PARAM_SUCESS = "42405"

/**
 * 车辆位姿
 */
const val XML_GROUP_ADDRESS_CAR_WEIZI = "44442"
const val XML_GROUP_ADDRESS_CAR_WEIZI_REVDATA = "9401"
const val XML_GROUP_ADDRESS_CAR_WEIZI_COUNT = 7

/**
 * 故障码 一组
 */
//const val XML_GROUP_ADDRESS_FAULT = "44200"
var XML_GROUP_ADDRESS_FAULT = "44460"
var XML_REV_FAULT = "10001"


/**
 * 通讯握手
 * 平板与wifi 连接成功之后，开始循环写入这个值
 * 直到收到反馈为止，再去做收发工作
 */
var XML_ADDRESS_WRITE_START_WORK = "43709"
var XML_VALUE_WRITE_START_WORK = "12345"


/**
 * 仿真
 */
var XML_ADDRESS_SIMULATION_HEART = "44360" //仿真心跳
var XML_ADDRESS_SIMULATION_OPEN = "43710"
var XML_ADDRESS_SIMULATION_DATAHEAD = "44362"
var XML_ADDRESS_SIMULATION_CHOOSE = "44361" //仿真选择

const val XML_SPECIAL = "special"

//todo 可以在xml中 添加设置
const val XML_DEVICE_NAME_GCH10 = "GCH10"
//const val XML_DEVICE_NAME_GWH23 = "GWH23"
//const val XML_DEVICE_NEW_NAME_GWH23 = "GWH23/GZH21/GWH19" //GWH23 改名成 GWH23/GZH21/GWH19

/**
 * 外部存储
 * 用户可以查看，应用删除不受影响
 */
fun getFileBasePath(): String {
    getMuMuFileSharedPath().also {
        if (it != null) {
            return it
        }
    }
    return getExternalStorageDirectory().absolutePath + "/hzaichi/"
}

/**
 * 外部存储
 * mumu模拟器共享地址 方便工人拷贝excel 文件
 */
fun getMuMuFileSharedPath(): String? {
    if (File(getExternalStorageDirectory().absolutePath + "/\$MuMu12Shared/").exists()) {
        return getExternalStorageDirectory().absolutePath + "/\$MuMu12Shared/"
    }
    return null
}


/**
 * 获取内部存储
 * 用户无法查看，可以通过root 查看，应用删除不受影响
 */
fun getInternalBasePath(context: Context): String {
    return context.filesDir.absolutePath
}

